/*
 * @(#)ArticleCleaner.java, 2024/2/21 10:19
 *
 * Copyright (c) 2018-2024, 四川蜀天梦图数据科技有限公司.
 * All rights reserved.
 */
package controllers;

import org.jsoup.Jsoup;
import org.springframework.web.util.HtmlUtils;

/**
 * ArticleCleaner
 *
 * @author fantazy
 * @version 1.0, 2024年02月21日
 */
public class ArticleCleaner
{

    private static final String WHITE_LINE_REGX = "\\s{2,}";
    private static final String HTML_TAG_REGEX = "<[^>]+>";
    public ArticleCleaner(){

    }

    public String clean(String content){
        final String s = Jsoup.parse(content).text();//content.replaceAll(HTML_TAG_REGEX,"");
        return s.replaceAll(WHITE_LINE_REGX, " ");
    }

    public static void main(String[] args)
    {
        String content = "Im a    boy      " +
                "";
        System.out.println(new ArticleCleaner().clean(content));
    }
}
